package com.gs.synedocket.dialog;

import android.content.Context;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gs.synedocket.R;


public class SureDialog extends BaseDialog {

    private Context context;
    private String titleStr;

    public SureDialog(@NonNull Context context, int title, IDoneListener iDoneListener) {
        super(context, R.style.custom_dialog);
        this.context = context;
        this.titleStr = context.getString(title);
        this.iDoneListener = iDoneListener;
    }

    public SureDialog(@NonNull Context context, String titleStr, IDoneListener iDoneListener) {
        super(context, R.style.custom_dialog);
        this.context = context;
        this.titleStr = titleStr;
        this.iDoneListener = iDoneListener;
    }

    @Override
    public void refreshView() {
    }

    @Override
    public void initView() {
        TextView tvTitle = findViewById(R.id.tv_title);
        tvTitle.setText(context.getString(R.string.are_you_sure, titleStr));
        findViewById(R.id.btn_cancel).setOnClickListener(v -> dismiss());
        findViewById(R.id.btn_yes).setOnClickListener(v -> {
            if (iDoneListener != null) {
                iDoneListener.getDoneFromDialog();
            }
            dismiss();
        });
    }

    @Override
    public int getLayoutId() {
        return R.layout.dialog_sure;
    }

    private IDoneListener iDoneListener;

    public interface IDoneListener {
        void getDoneFromDialog();
    }
}
